#ifndef QOPENHARMONYWINDOWCONTROL_H
#define QOPENHARMONYWINDOWCONTROL_H

#include "qvideowindowcontrol.h"
#include <napi/native_api.h>
#include <multimedia/player_framework/avplayer.h>
#include <ace/xcomponent/native_interface_xcomponent.h>

struct OH_NativeXComponent;
struct OH_NativeXComponent_Callback;
QT_BEGIN_NAMESPACE
class QOpenHarmonyPlayerControl;
class QOpenHarmonyWindowControl : public QVideoWindowControl
{
    Q_OBJECT
public:
    QOpenHarmonyWindowControl(QObject *parent = nullptr);
    ~QOpenHarmonyWindowControl() override;

    WId winId() const override;
    void setWinId(WId id) override;

    QRect displayRect() const override;
    void setDisplayRect(const QRect &rect) override;

    bool isFullScreen() const override;
    void setFullScreen(bool fullScreen) override;

    void repaint() override;

    QSize nativeSize() const override;

    Qt::AspectRatioMode aspectRatioMode() const override;
    void setAspectRatioMode(Qt::AspectRatioMode mode) override;

    int brightness() const override;
    void setBrightness(int brightness) override;

    int contrast() const override;
    void setContrast(int contrast) override;

    int hue() const override;
    void setHue(int hue) override;

    int saturation() const override;
    void setSaturation(int saturation) override;

    void setNativeXComponent(OH_NativeXComponent *nativeXComponent);
    void setNativeWindow(OHNativeWindow *nativeWindow);
    OHNativeWindow *nativeWindow() const;

    void setPlayerControl(QOpenHarmonyPlayerControl *control);
    static void onSurfaceCreated(OH_NativeXComponent* component, void* window);
    static void init(napi_env env, napi_value exports);

signals:
    void windowCreated();
private:
    WId m_windowId = 0;
    OH_NativeXComponent_Callback *m_callback;
    OHNativeWindow *m_nativeWindow = nullptr;
    QString m_name;
    Qt::AspectRatioMode m_aspectRatioMode = Qt::KeepAspectRatio;
    QRect m_displayRect;
    int m_brightness = 0;
    int m_contrast = 0;
    int m_hue = 0;
    int m_saturation = 0;
    bool m_fullScreen = false;
    QOpenHarmonyPlayerControl *m_playerControl;
};

QT_END_NAMESPACE

#endif
